package com.cn.ryc.mapper;

import com.cn.ryc.model.Staff;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StaffMapper {

    @Select("SELECT * FROM staff WHERE id = #{id}")
    Staff findById(@Param("id") Long id);

    @Select("SELECT * FROM staff")
    // 查询staff表中的所有数据
    List<Staff> findAll();

    @Insert("INSERT INTO staff (name, role, area, phone, email, status) " +
            "VALUES (#{name}, #{role}, #{area}, #{phone}, #{email}, #{status})")
    // 使用自动生成的主键
    @Options(useGeneratedKeys = true, keyProperty = "id")
    // 插入员工信息
    void insertStaff(Staff staff);

    @Update("UPDATE staff SET name = #{name}, role = #{role}, area = #{area}, phone = #{phone}, email = #{email}, status = #{status} WHERE id = #{id}")
    // 更新员工信息,不能更新ID_card
    void updateStaff(Staff staff);

    // 删除员工信息
    @Delete("DELETE FROM staff WHERE id = #{id}")
    void deleteStaff(@Param("id") Long id);
} 